Skip to content

Allow unpinned requirements to use hashes from constraints#13887

Open
pradyunsg wants to merge 1 commit intopypa:mainfrom
pradyunsg:resolver-constraints-pins-hashes
Open

Allow unpinned requirements to use hashes from constraints#13887
pradyunsg wants to merge 1 commit intopypa:mainfrom
pradyunsg:resolver-constraints-pins-hashes

Conversation

@pradyunsg
Copy link
Copy Markdown
Member

Closes #9243, I think?

This is now a tomorrow thing for me. Gotta go to PyCon US stuff now.

@pradyunsg pradyunsg force-pushed the resolver-constraints-pins-hashes branch from 5ce88cb to dac19f2 Compare April 6, 2026 10:47
Comment on lines +60 to +63
hash_options = {
alg: [v for v in other.hash_options[alg] if v in self.hash_options[alg]]
for alg in self.hash_options.keys() & other.hash_options.keys()
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should multiple entries for the same requirement get unioned or intersected?

Right now, this mirrors Hashes.__and__: uses as-is when one side is empty, intersection of them when both are present.

Constraints with `==version --hash=...` correctly narrow the candidate
set, but the per-candidate `InstallRequirement` still reflected the
original unpinned and hashless requirement.

In such a configuration, plumb through the hashes from the constraints
to the per-candidate `InstallRequirement`, and pin it to the version
from the link (which is informed by the constraint). This makes
hashes get correctly used for candidate selection and verification, at
the cost of a few copies at the start of the resolve in such cases.
@pradyunsg pradyunsg force-pushed the resolver-constraints-pins-hashes branch from dac19f2 to 3cd1be1 Compare April 6, 2026 20:26
@pradyunsg pradyunsg marked this pull request as ready for review April 6, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[regression] resolvelib-based dependency processing of constraints with hashes fails to "see" the exact pins

1 participant